<template>
  <div id="backcont">
    <div class="Quiz-content">
      <div class="login-cont">
        <div class="MBTI-title">MBTI职业性格测试管理</div>
        <div class="MBTI-user">
          <p>学号</p>
          <el-input clearable v-model="studentId" class="inptflex" placeholder="请输入学号" />
        </div>
         <div class="MBTI-user">
          <p>密码</p>
          <el-input show-password v-model="passwrod" class="inptflex" placeholder="请输入密码" />
        </div>
        <!-- 登录和注册按钮的切换 -->
        
        <!-- 登录或注册按钮的提交 -->
        <el-button @click="signin" class="denglu-btn">登录</el-button>

     
      </div>
    </div>
  </div>
 
</template>


<script>
import { ElMessage } from 'element-plus'
import {useRouter} from 'vue-router'
import { reactive,toRefs,getCurrentInstance  } from 'vue'
export default{
  setup(){
    const {proxy} = getCurrentInstance()//取到全局属性和方法
    const router = useRouter()
    const user = reactive({
      studentId:'',
      passwrod:'',

    })

    //登录,进行传值在request.js文件中收
    const signin = ()=>{

      if (!user.passwrod || !user.studentId) {
        ElMessage.warning({
          message: "警告,请先填写账号和密码",
          type: "warning",
        });
        return;
      }else if(user.studentId!="admin" || user.passwrod!="123456"){
         ElMessage.warning({
          message: "账号或密码错误！",
          type: "warning",
        });
        return;
      }
          router.push({
          path: "/home",
      });

    }

   

  

   
    return{...toRefs(user), signin, proxy}
  }
}

</script>


<style >

</style>
